<template>
  <q-dialog class="my-dialog-form" v-model="isFlagShow" style="margin-left:20px">
    <q-card class="my-card q-mx-lg" >
      <q-toolbar class="row items-center my-form-header">
        <div>
          {{dlgTitle}}
        </div>
        <q-space />
        <q-btn flat round dense icon="mdi-close" @click="close"/>
      </q-toolbar>
      <q-separator />
      <q-uploader tyle="margin:30px" 
          :factory="factoryFn" 
          label="选择excel文件" 
          :multiple="false" 
          accept=".xls,.xlsx" 
          height="30px"></q-uploader>
    </q-card>
  </q-dialog>
</template>
  
<script lang="ts">
import { defineAsyncComponent, defineComponent, onMounted, ref, toRefs, PropType, watch, toRef } from 'vue';
import api from 'axios'
import { sysBaseUrlAPI } from '../../../util/SysBaseConst';
import { useCommonStore } from 'src/stores/commonStore';
import { storeToRefs } from 'pinia';

export default defineComponent({
  cname: 'CompanyUploadDlg',
  components: {
      
  },
  setup (props, context) {
  
    //*******************************
    //      表单项
    //*******************************
    //窗口显示
    let isFlagShow = ref(false);
    
    //窗口标题
    let dlgTitle = ref('上传公司信息');

    const show = (text: string) => {
      isFlagShow.value = true;
      dlgTitle.value = text;
    }
    
    const factoryFn = (files: ArrayBuffer) => {
      let commonStore = useCommonStore();
      const { token } = storeToRefs(commonStore);      
      return {
        url: sysBaseUrlAPI.SYS_COMPANY_API_UPLOAD,
        headers: [{ name: 'Authorization', value: token.value }],
        fieldName: 'file',
        method: 'POST',
      }
    }

    //关闭窗口
    const close = () => {
      isFlagShow.value = false;
    }
        
    return {
      isFlagShow,
      dlgTitle,
      factoryFn,
      show,
      close
    }
  }
})
</script>
  
  <style lang="scss" scoped>
  .my-card {
    alignment: center;
    width: 600px;
    max-width: 800px;
  
    .my-form-container {
      text-align: center;
      padding: 5px 50px 5px 50px;
      height: 430px;
    }
  }
  </style>  
